<template>
  <!-- 预览简历 -->
  <view
    class="box"
    @click=";(moreChage = false), (informationNoBubbles = false)"
    @touchstart="handleTouchStart"
    @touchmove="handleTouchMove"
    @touchend="handleTouchEnd"
  >
    <view class="dengLoadingVue" v-if="loding">
      <view class="maskVueHiddenShow">
        <view class="maskVueHiddenShowWrapper">
          <view class="loader">
            <view class="inner one"></view>
            <view class="inner two"></view>
            <view class="inner three"></view>
          </view>
          <view class="loding"> 数据加载中，请稍后... </view>
        </view>
      </view>
    </view>

    <view v-if="!loding">
      <view class="head">
        <view class="title">
          <image
            class="fanhui"
            @click.stop="goBack"
            src="https://pic.bangbangtongcheng.com/static/bbzc/left-btn.png"
            mode=""
          >
          </image>
          <view class="title-text">
            <span>我的简历</span>
            <!-- 2.28修改 -->
            <span v-if="caozuoType == 0" class="view-resume">
              <span style="margin-right: 20rpx">隐藏简历</span>
              <u-switch
                v-model="curriculumVitae.whetherHide"
                asyncChange
                activeColor="#0FA291"
                size="20"
                @change="switchChange"
              ></u-switch>
              <!-- #ifdef APP-PLUS -->
              <img
                class="share-resume"
                src="https://pic.bangbangtongcheng.com/static/bbzc/share-resume.png"
                alt=""
                @click="shareResume"
              />
              <!-- #endif -->
            </span>
          </view>
        </view>
      </view>

      <view class="main">
        <!-- 基本信息 -->
        <view class="section">
          <view class="section-title">
            <span class="title-line"></span>
            基本信息
          </view>
          <view class="form-item">
            <span class="label"
              >姓<span style="display: inline-block; width: 55rpx"></span>名：</span
            >
            <span class="text">{{ curriculumVitae.realName }}</span>
          </view>
          <view class="form-item">
            <span class="label"
              >性<span style="display: inline-block; width: 55rpx"></span>别：</span
            >
            <span class="text">{{ curriculumVitae.sexualDistinction === '1' ? '男' : '女' }}</span>
          </view>
          <view class="form-item">
            <span class="label"
              >年<span style="display: inline-block; width: 55rpx"></span>龄：</span
            >
            <span class="text">{{ curriculumVitae.age }}岁</span>
          </view>
          <view class="form-item">
            <span class="label"
              >学<span style="display: inline-block; width: 55rpx"></span>历：</span
            >
            <span class="text">{{ curriculumVitae.highestEducation }}</span>
          </view>
          <view class="form-item">
            <span class="label">工作经验：</span>
            <span class="text">
              {{ curriculumVitae.workYear }}年 | {{ curriculumVitae.workingTime }}年参加工作
            </span>
          </view>
          <view class="form-item">
            <span class="label">现居地址：</span>
            <span class="text">{{ homeAddress }}</span>
          </view>
          <view class="form-item">
            <span class="label">自我介绍：</span>
            <span class="text">{{ curriculumVitae.introduction || '-' }}</span>
          </view>
          <!-- 头像 -->
          <img
            class="avator"
            :src="curriculumVitae.myPhoto || 'https://pic.bangbangtongcheng.com/static/avator.png'"
            alt=""
          />
        </view>

        <!-- 工作意向 -->
        <view class="section">
          <view class="section-title">
            <span class="title-line"></span>工作意向
            <view class="right-text">{{
              curriculumVitae.jobStatus === '1' ? '离职，随时到岗' : '在职，考虑机会'
            }}</view>
          </view>
          <view class="form-item" style="flex-wrap: wrap; width: 100%">
            <span class="form-item-tag" v-for="(item,index) in intendedPositionList" :key="index">{{ item }}</span>
          </view>
          <view class="form-item">
            <span class="label">求职类型：</span>
            <span class="text" v-if="curriculumVitae.jobType === '0'">全职</span>
            <span class="text" v-if="curriculumVitae.jobType === '1'">兼职</span>
            <span class="text" v-if="curriculumVitae.jobType === '2'">全职兼职均可</span>
          </view>
          <view class="form-item">
            <span class="label">期望薪资：</span>
            <span class="text">{{ curriculumVitae.salaryExpectation }}</span>
          </view>
          <view class="form-item">
            <span class="label">工作区域：</span>
            <span class="text">{{ workLocationText }}</span>
          </view>
        </view>

        <!-- 教育经历 -->
        <view class="section">
          <view class="section-title"> <span class="title-line"></span>教育经历 </view>
          <view class="form-item">
            <span class="label">毕业院校：</span>
            <span class="text">{{ curriculumVitae.graduationAcademy.schoolName || '-' }}</span>
          </view>
          <view class="form-item">
            <span class="label">所学专业：</span>
            <span class="text">{{ curriculumVitae.graduationAcademy.major || '-' }}</span>
          </view>
          <view class="form-item">
            <span class="label">毕业时间：</span>
            <span class="text">{{ curriculumVitae.graduationAcademy.schoolHours || '-' }}</span>
          </view>
          <view class="form-item" style="flex-wrap: wrap; align-items: flex-start">
            <span class="label" style="padding-top: 8rpx">获得荣誉：</span>
            <span style="flex: 1;padding-top: 8rpx">
              <span class="text"  v-if="curriculumVitae.graduationAcademy.honorReceived.length == 0">{{'-'}}</span>
              <span
                class="form-item-tag"
                v-for="(item,index) in curriculumVitae.graduationAcademy.honorReceived"
                :key="index"
                >{{ item }}</span
              >
            </span>
          </view>
          <view class="form-item">
            <span class="label">学习经历：</span>
            <view>
              <u-read-more ref="expMore" class="text" :toggle="true" showHeight="48" textIndent="0">
                <rich-text :nodes="curriculumVitae.graduationAcademy.associationActivity?curriculumVitae.graduationAcademy.associationActivity.replace(/\n/g, '<br>') :'-'"></rich-text>
                <!-- <u-parse v-show="false"
                  :content="curriculumVitae.graduationAcademy.associationActivity?curriculumVitae.graduationAcademy.associationActivity.replace(/\n/g, '<br>') :'-'"
                ></u-parse> -->
              </u-read-more>
            </view>
          </view>
        </view>

        <!-- 工作经历 -->
        <view
          class="section"
          v-for="(item, index) in curriculumVitae.workExperience"
          :key="index"
        >
          <view class="section-title"> <span class="title-line"></span>工作经历 </view>
          <view class="form-item">
            <span class="label">公司名称：</span>
            <span class="text">{{ item.corporateName || '-' }}</span>
          </view>
          <view class="form-item">
            <span class="label">职位类别：</span>
            <span class="text">{{ item.positionNameText || '-' }}</span>
          </view>
          <view class="form-item">
            <span class="label">在职时间：</span>
            <span class="text">{{ item.onJobTime || '-' }}</span>
          </view>
          <view class="form-item">
            <span class="label">薪资范围：</span>
            <span class="text">{{ item.salaryRange || '-' }}</span>
          </view>
          <view class="form-item">
            <span class="label">工作描述：</span>
            <view>
              <u-read-more
                ref="uReadMore"
                class="text"
                :toggle="true"
                showHeight="200"
                textIndent="0"
              >
                <rich-text :nodes="item.jobContent?item.jobContent.replace(/\n/g, '<br>') : '-'"></rich-text>
                <!-- <u-parse :content="item.jobContent?item.jobContent.replace(/\n/g, '<br>') : '-'" :confirm-type="null"></u-parse> -->
              </u-read-more>
            </view>
          </view>
          <view class="form-item" style="flex-wrap: wrap; align-items: flex-start">
            <span class="label" style="padding-top: 8rpx">个人优势：</span>
            <span v-if="item.personalAdvantage.length > 0" style="flex: 1;padding-top: 8rpx">
              <span
                class="form-item-tag"
                v-for="(v, i) in item.personalAdvantage"
                :key="i"
                >{{ v.valueName }}</span
              >
            </span>
            <span class="text" style="flex: 1;padding-top: 8rpx" v-else>-</span>
          </view>
        </view>

        <!-- 加分项 -->
        <view class="section">
          <view class="section-title"> <span class="title-line"></span>加分项 </view>

          <view
            v-if="
              curriculumVitae.bonusItem.trainingExperience &&
              curriculumVitae.bonusItem.trainingExperience.length > 0
            "
          >
            <view
              class="form-item bonus-item"
              v-for="(item, index) in curriculumVitae.bonusItem.trainingExperience"
              :key="index"
            >
              <span class="label">培训经历：</span>
              <view class="content">
                <view>{{ item.trainingCourse }}</view>
                <view class="second-line flex_end">
                  <span>{{ item.trainingInstitutions }}</span>
                  <span>{{ item.trainingTime }}</span>
                </view>
              </view>
            </view>
          </view>
          <view v-else>
            <view class="form-item bonus-item">
              <span class="label">培训经历：</span>
              <view class="content">-</view>
            </view>
          </view>

          <view
            v-if="
              curriculumVitae.bonusItem.languageAbility &&
              curriculumVitae.bonusItem.languageAbility.length > 0
            "
          >
            <view
              class="form-item bonus-item"
              v-for="(item, index) in curriculumVitae.bonusItem.languageAbility"
              :key="index"
            >
              <span class="label">语言能力：</span>
              <view class="content">
                <span>{{ item.languages }}</span>
                <span style="padding: 0 10rpx" v-if="item.listeningSpeakingAbility">/</span>
                <span v-if="item.listeningSpeakingAbility === '1'">听说能力一般</span>
                <span v-if="item.listeningSpeakingAbility === '2'">听说能力良好</span>
                <span v-if="item.listeningSpeakingAbility === '3'">听说能力熟练</span>
                <span v-if="item.listeningSpeakingAbility === '4'">听说能力精通</span>
                <span style="padding: 0 10rpx" v-if="item.readingWritingAbility">/</span>
                <span v-if="item.readingWritingAbility === '1'">读写能力一般</span>
                <span v-if="item.readingWritingAbility === '2'">读写能力良好</span>
                <span v-if="item.readingWritingAbility === '3'">读写能力熟练</span>
                <span v-if="item.readingWritingAbility === '4'">读写能力精通</span>
              </view>
            </view>
          </view>
          <view v-else>
            <view class="form-item bonus-item">
              <span class="label">语言能力：</span>
              <view class="content">-</view>
            </view>
          </view>

          <view
            v-if="
              curriculumVitae.bonusItem.qualification &&
              curriculumVitae.bonusItem.qualification.length > 0
            "
          >
            <view
              class="form-item bonus-item"
              v-for="(item, index) in curriculumVitae.bonusItem.qualification"
              :key="index"
            >
              <span class="label">资质证书：</span>
              <view class="content">
                <span>{{ item.getTime }}荣获</span>
                <span style="padding: 0 10rpx">/</span>
                <span>{{ item.certificateName }}资格证书</span>
              </view>
            </view>
          </view>
          <view v-else>
            <view class="form-item bonus-item">
              <span class="label">资质证书：</span>
              <view class="content">-</view>
            </view>
          </view>

          <view
            v-if="
              curriculumVitae.bonusItem.professionalSkills &&
              curriculumVitae.bonusItem.professionalSkills.length > 0
            "
          >
            <view
              v-for="(item, index) in curriculumVitae.bonusItem.professionalSkills"
              :key="index"
            >
              <view class="form-item bonus-item">
                <span class="label">专业技能：</span>
                <view v-if="item.skillName" class="content">
                  <span>{{ item.skillName }}</span>
                  <span style="padding: 0 10rpx">/</span>
                  <span v-if="item.mastery === '1'">一般掌握</span>
                  <span v-if="item.mastery === '2'">良好掌握</span>
                  <span v-if="item.mastery === '3'">熟练掌握</span>
                  <span v-if="item.mastery === '4'">精通掌握</span>
                  <span style="padding: 0 10rpx">/</span>
                  <span v-show="item.duration">{{ item.duration }}年</span>
                </view>
                <view v-else class="content">
                  -
                </view>
              </view>

              <view class="form-item bonus-item">
                <span class="label">证书/作品：</span>
                <view
                  v-if="item.certificateWorks.length > 0"
                  class="content certificateworks"
                  style="line-height: 0"
                >
                  <scroll-view class="scroll-view-x" scroll-x scroll-with-animation >
                    <image
                      class="img"
                      mode="aspectFit"
                      v-for="(item2, index2) in item.certificateWorks"
                      :key="index2"
                      :src="item2"
                      alt=""
                      @click="handlePreview(item2)"
                    />
                  </scroll-view>
                </view>
                <view v-else class="content">-</view>
              </view>
            </view>
          </view>
          <view v-else>
            <view class="form-item bonus-item">
              <span class="label">专业技能：</span>
              <view class="content">-</view>
            </view>
            <view class="form-item bonus-item">
              <span class="label">证书/作品：</span>
              <view class="content">-</view>
            </view>
          </view>
        </view>

        <view class="section">
          <view class="section-title">
            <span class="title-line"></span>当前简历对谁可见：
            <span>{{ curriculumVitae.visibleRange == '1' ? '全部可见' : '认证企业可见' }}</span>
          </view>
        </view>
      </view>

      <!-- 预览图片 -->
      <u-overlay :show="previewPic" @click="previewPic = false">
        <view class="preview-warp">
          <image mode="widthFix" :src="previewPicSrc" alt="" />
        </view>
      </u-overlay>
    </view>
  </view>
</template>
<script>
  //#ifdef H5
  import wxshare from '@/utils/index.js'
  //#endif
  import { mapGetters } from 'vuex'
  import { getYear } from '../../util/dateTimePicker.js'
  import imageUploadCropper from '@/components/imageUploadCropper.vue'
  import { district } from '@/util/enum.js'
  import _ from 'lodash'
  import { formatDateAdjusted } from '@/util/dateTimePicker.js'

  export default {
    components: {
      imageUploadCropper,
    },
    data() {
      return {
        loding: true,
        caozuoType: 0, //0我的简历  1预览简历

        userInfo: uni.getStorageSync('Pduser'),
        homeAddress: '', // 优化后的地址
        curriculumVitae: {
          id: '',
          publisherId: '', //发布人ID
          whetherHide: false, // 隐藏简历
          resumeCompleteness: 0, //综合得分
          myPhoto: '', //本人照片
          realName: '', //真实姓名
          age: '',
          sexualDistinction: '', //性别（1：男，2：女）
          jobStatus: '', //在职状态 *****
          dateBirth: 1995, //出生年
          cellphoneNumber: '', //手机号
          workingTime: 0, //参加工作时间
          experienceYears: 0,
          graduationAcademy: {
            schoolName: '', // 毕业院校
            major: '', // 所学专业
            schoolHours: '', //毕业时间
            associationActivity: '', // 学习经历
            honorReceived: [], // 获得荣誉
          }, //毕业院校
          //工作经历
          workExperience: [],
          highestEducation: '本科', //最高学历
          homeAddress: '', //家庭地址
          longitude: '', //经度
          latitude: '', //纬度
          workLocation: '[]', // 工作地区 ******
          intendedPosition: '', //意向职位
          salaryExpectation: '5001-8000元', //目标收入
          jobType: '', // 求职类型 *****
          introduction: '', // 自我介绍 *****
          //加分项
          bonusItem: {
            trainingExperience: [],
            languageAbility: [],
            professionalSkills: [],
            qualification: [],
          },
          visibleRange: '1', //对谁可见（1-全部可见、2-认证企业可见、3-招聘相应职位可见）
          dateIndex: [0, 0], // 毕业院校index
        },
        imgList: [], // 头像
        addImgUrl: 'https://pic.bangbangtongcheng.com/static/bbzc/upload.png',
        intendedPositionList: [],
        salaryExp: [], // 目标收入枚举
        district: JSON.parse(JSON.stringify(district)), // 地区枚举，务必重新指向一次新地址，以免缓存中会反复影响
        workLocationText: '', // 工作地区文本
        selectorDistrict: false, // 工作地区选择器容器
        type3: [], // 学历数据
        describe: '请输入学习经历:\n1.描述您在学校的学习情 \n2.描述您在校担任过的职务和获得的荣誉',
        studyList: [], // 学习经历示例列表
        associationActivityTem: '', // 当前学习经历模板
        workHours: [], // 在职起始时间年份options
        workHours_month: [], // 在职起始时间月份options
        workHours2: [], // 在职结束时间年份options
        workHours2_month: [], // 在职结束时间月份options
        dateIndex1: [0, 0],
        dateIndex2: [0, 0],
        educationKey: 1000,
        workExpIndex: 0, // 工作经历数组索引
        workExpKey: 0,
        workList: [], // 工作经历示例模板
        workText: '', //工作经历
        trianingIndex: 0, // 培训经历序号
        languagesOption: ['英语', '法语', '日语', '韩语', '西班牙语'],
        languageIndex: 0, // 语言能力序号
        qualificationIndex: 0, // 资质证书序号
        skillsIndex: 0, // 专业技能序号
        checked: false, // 同意发布
        scrollIntoViewId: '',
        bonusKey: 0, // 加分项key
        advanceOption: [], // 个人优势列表枚举
        isFixed: false,
        tabActive: 'a',
        baseInfoCount: 0, // 基本信息未填项统计
        intentionCount: 0, // 工作意向未填项统计
        educationCount: 0, // 教育经历未填项统计
        workExpCount: 0, // 工作经历未填项统计
        bonusItemCount: 0, // 加分项未填项统计
        customHonor: '',
        honorCount: 0,
        newCurriculumVitae: {},
        previewPic: false, // 预览证书图片
        previewPicSrc: '', // 预览图片地址
      }
    },
    onLoad(option) {
      // 获取微信小程序胶囊和据右边宽度
      // 获取胶囊信息
      // #ifdef MP-WEIXIN
      let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
      let getWindowInfo = uni.getWindowInfo().screenWidth
      this.WXwidth = getWindowInfo - (menuButtonInfo.right - menuButtonInfo.width)
      // #endif

      if (option.index) {
        this.index = option.index
      }
      if (option.type) {
        this.caozuoType = option.type
      }

      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
    },
    onShow() {
      //初始化
      this.init()
    },
    computed: {
      ...mapGetters(['userid', 'islogin', 'statusBarHeight1', 'userinfo']),
    },
    methods: {
      init() {
        const data = {
          publisherId: this.userInfo.id,
        }
        this.$myRequest.get('/api/mobile/personnelOwner/getSelfResumeDetails', data).then((res) => {
          if (res.biographicalNotesDetails) {
            let obj = res.biographicalNotesDetails;
            // 如果没有缓存数据,则以接口数据为准
            this.curriculumVitae = {
              ...this.curriculumVitae,
              ...obj,
            }
            // 回显需要特殊处理的表单数据
            this.echoData()
          }
        })
      },
      // 地址逆解析
      addressAnalyze(address) {
        let that = this;
        uni.request({
          url: `https://restapi.amap.com/v3/geocode/geo?address=${address}&key=42933539a9d7c73982510a357f504624`,
          success: (res) => {
            const addr = res.data.geocodes[0];
            that.homeAddress = `${addr.province}${addr.city}${addr.district}${addr.street}`;
          },
        })
      },
      // 回显需要特殊处理的表单数据
      echoData() {
        console.log('this.curriculumVitae', this.curriculumVitae)
        // 回显头像
        if (this.curriculumVitae.myPhoto) {
          this.imgList = [this.curriculumVitae.myPhoto]
        } else {
          this.setDefaultAvator(this.curriculumVitae.sexualDistinction)
        }

        // 回显参加工作时间
        // 计算工作经验
        const newDate = new Date()
        const year = newDate.getFullYear()
        if (this.curriculumVitae.workingTime) {
          // 工作经验(后端返回数据不稳定)
          if (this.curriculumVitae.workingTime.length > 4) {
            this.curriculumVitae.workingTime = this.curriculumVitae.workingTime.slice(0, 4)
          }
          this.curriculumVitae.workYear = year - Number(this.curriculumVitae.workingTime)
        }

        // 回显现居地址
        if (this.curriculumVitae.homeAddress) {
          this.addressAnalyze(this.curriculumVitae.homeAddress);
        }

        // 回显意向职位
        if (this.curriculumVitae.intendedPosition) {
          // 意向职位回显
          this.intendedPositionList = []
          if (this.curriculumVitae.intendedPosition) {
            let intendedPosition = JSON.parse(this.curriculumVitae.intendedPosition)
            // console.log('intendedPositionList', typeof(intendedPositionList));
            intendedPosition.length > 0 &&
              intendedPosition.map((v) => {
                let itemArr = v.split(',')
                this.intendedPositionList.push(itemArr[itemArr.length - 1])
              })
            // console.log('intendedPositionList', this.intendedPositionList);
          }
        }
        // 回显教育经历：毕业院校、毕业时间、学历、学习经历
        if (this.curriculumVitae.graduationAcademy) {
          if (typeof this.curriculumVitae.graduationAcademy == 'string') {
            this.curriculumVitae.graduationAcademy = JSON.parse(
              this.curriculumVitae.graduationAcademy
            )
          }
          // console.log('graduationAcademy', this.curriculumVitae.graduationAcademy);
          let graduationAcademy = this.curriculumVitae.graduationAcademy
          if (graduationAcademy.schoolName) {
            graduationAcademy.schoolName = graduationAcademy.schoolName
          }
          if (graduationAcademy.schoolHours) {
            graduationAcademy.schoolHours = formatDateAdjusted(graduationAcademy.schoolHours)
          }
          if (graduationAcademy.associationActivity) {
            this.curriculumVitae.associationActivity = graduationAcademy.associationActivity
          }
          if (typeof graduationAcademy.honorReceived === 'string') {
            graduationAcademy.honorReceived = graduationAcademy.honorReceived.split(',')
            console.log('graduationAcademy.honorReceived', graduationAcademy.honorReceived)
          } else {
            graduationAcademy.honorReceived = []
          }
        }

        // 回显意向工作地址
        if (this.curriculumVitae.workLocation) {
          const workLocation = JSON.parse(this.curriculumVitae.workLocation)
          console.log('workLocation', workLocation)
          this.workLocationText = []
          this.district.forEach((item1) => {
            const match = workLocation.find((item2) => item2.label === item1.label)
            if (match) {
              item1.checked = true
              this.workLocationText += item1.label + ' '
            }
          })
        }

        // 回显工作经历
        if (this.curriculumVitae.workExperience) {
          // console.log('this.curriculumVitae.workExperience', this.curriculumVitae.workExperience);
          if (typeof this.curriculumVitae.workExperience === 'string') {
            this.curriculumVitae.workExperience = JSON.parse(this.curriculumVitae.workExperience)
          }

          let workExperience = this.curriculumVitae.workExperience
          // console.log('this.curriculumVitae.workExperience', this.curriculumVitae.workExperience);
          // 有工作经验数据
          if (Array.isArray(workExperience) && workExperience.length > 0) {
            workExperience.map((item) => {
              item.positionNameText = ''
              console.log('item', item)

              // 回显职位
              if (item.positionName) {
                let positionName = JSON.parse(item.positionName)
                if (Array.isArray(positionName) && positionName.length > 0) {
                  positionName.map((v) => {
                    let itemArr = v.split(',')
                    item.positionNameText += itemArr[itemArr.length - 1] + ' '
                  })
                }
              }

              // 在职时间
              if (item.onJobTime) {
                const onJobTime = item.onJobTime.split('|')
                console.log('onJobTime', onJobTime)
                item.startTime = onJobTime[0] ? onJobTime[0] : ''
                item.endTime = onJobTime[1] ? onJobTime[1] : ''
                item.onJobTime = `${formatDateAdjusted(item.startTime)} 至 ${formatDateAdjusted(
                  item.endTime
                )}`
              }

              // 回显个人优势
              if (typeof item.personalAdvantage === 'string') {
                item.personalAdvantage = JSON.parse(item.personalAdvantage)
                item.personalAdvantage = item.personalAdvantage.filter((item) => item.checked)
              } else {
                item.personalAdvantage = []
              }
              console.log('item.personalAdvantage', item.personalAdvantage)
            })
          } else {
            //没有工作经验数据
            this.curriculumVitae.workExperience = [
              {
                corporateName: '',
                hideSwitch: true,
                industry: '',
                jobContent: '',
                onJobTime: '',
                positionName: '[]',
                positionNameText: '',
                startTime: '',
                salaryRange: '',
                personalAdvantage: [...this.advanceOption],
              },
            ]
          }
        }

        // console.log('this.curriculumVitae.bonusItem', this.curriculumVitae.bonusItem);

        // 加分项
        if (
          typeof this.curriculumVitae.bonusItem === 'string' &&
          this.curriculumVitae.bonusItem !== ''
        ) {
          this.curriculumVitae.bonusItem = JSON.parse(this.curriculumVitae.bonusItem)
          this.curriculumVitae.bonusItem.trainingExperience = this.curriculumVitae.bonusItem
            .trainingExperience
            ? JSON.parse(this.curriculumVitae.bonusItem.trainingExperience)
            : []
          this.curriculumVitae.bonusItem.languageAbility = this.curriculumVitae.bonusItem
            .languageAbility
            ? JSON.parse(this.curriculumVitae.bonusItem.languageAbility)
            : []
          this.curriculumVitae.bonusItem.qualification = this.curriculumVitae.bonusItem
            .qualification
            ? JSON.parse(this.curriculumVitae.bonusItem.qualification)
            : []
          this.curriculumVitae.bonusItem.professionalSkills = this.curriculumVitae.bonusItem
            .professionalSkills
            ? JSON.parse(this.curriculumVitae.bonusItem.professionalSkills)
            : []

          console.log(
            'this.curriculumVitae.bonusItem.professionalSkills',
            this.curriculumVitae.bonusItem.professionalSkills
          )
          if (Array.isArray(this.curriculumVitae.bonusItem.trainingExperience)) {
            this.curriculumVitae.bonusItem.trainingExperience.map((v) => {
              if (v.trainingTime) {
                const time = v.trainingTime.split('至');
                v.trainingTime = `${formatDateAdjusted(time[0])}至${formatDateAdjusted(time[1])}`;
              }
            })
          }

          if (Array.isArray(this.curriculumVitae.bonusItem.qualification)) {
            this.curriculumVitae.bonusItem.qualification.map((v) => {
              if (v.getTime) {
                v.getTime = formatDateAdjusted(v.getTime)
              }
            })
          }
          if (Array.isArray(this.curriculumVitae.bonusItem.professionalSkills)) {
            this.curriculumVitae.bonusItem.professionalSkills.map((v) => {
              if (v.certificateWorks) {
                v.certificateWorks = JSON.parse(v.certificateWorks)
              } else {
                v.certificateWorks = []
              }
            })
          }
          // console.log('this.curriculumVitae.bonusItem', this.curriculumVitae.bonusItem);
        }
        this.loding = false
        console.log('this.curriculumVitae', this.curriculumVitae)
      },
      // 设置默认头像
      setDefaultAvator(sex) {
        // 从1-5中随机取数,给一个随机的默认头像
        const index = Math.floor(Math.random() * 5) + 1
        if (this.curriculumVitae.sexualDistinction == '1' || sex == '1') {
          // 男生头像
          this.curriculumVitae.myPhoto = `https://pic.bangbangtongcheng.com/static/bbzc/m1.png`
          this.imgList = [this.curriculumVitae.myPhoto]
        } else {
          // 女生头像
          this.curriculumVitae.myPhoto = `https://pic.bangbangtongcheng.com/static/bbzc/w1.png`
          this.imgList = [this.curriculumVitae.myPhoto]
        }
      },

      // 对这家公司隐藏我的信息
      switchChange(e) {
        console.log('e===', e)
        // e = !e
        uni.showModal({
          content: e ? '简历隐藏后，企业将无法查看您的简历，也无法与您沟通' : '确定要开放简历吗？',
          confirmText: '我再想想',
          cancelText: '确定',
          cancelColor: '#999999',
          confirmColor: '#0FA291',
          success: (res) => {
            if (res.cancel) {
              console.log('用户点击确定')
              const params = {
                userId: this.userInfo.id,
                ids: this.curriculumVitae.id,
                hideFlag: e ? 1 : 0,
              }
              this.$myRequest.post('/api/mobile/personnelOwner/hideResumeByIds', params)
              this.curriculumVitae.whetherHide = e
              //更新缓存中whetherHide值
              let curriculumVitae = uni.getStorageSync('curriculumVitae')
              curriculumVitae.whetherHide = e
              uni.setStorageSync('curriculumVitae', curriculumVitae)
            } else if (res.confirm) {
              console.log('用户点击取消')
            }
          },
        })
      },
      // 分享简历
      shareResume() {
        uni.showActionSheet({
          itemList: ['分享到微信好友', '分享到微信朋友圈'],
          success: (res) => {
            console.log('res.tapIndex ', res.tapIndex)
            if (res.tapIndex == 0) {
              //分享到好友
              uni.share({
                provider: 'weixin',
                scene: 'WXSceneSession',
                type: 0,
                href: 'https://pic.bangbangtongcheng.com/pages/index/index',
                title: '我的简历',
                summary: '我正在使用帮帮同城分享简历，赶紧跟我一起来体验！',
                imageUrl: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/share-logo@3.png',
                success: function (res) {
                  console.log('success:' + JSON.stringify(res))
                },
                fail: function (err) {
                  console.log('fail:' + JSON.stringify(err))
                },
              })
            } else {
              // 分享到朋友圈
              uni.share({
                provider: 'weixin',
                scene: 'WXSceneTimeline',
                type: 0,
                href: 'https://pic.bangbangtongcheng.com/pages/index/index',
                title: '我的简历',
                summary: '我正在使用帮帮同城分享简历，赶紧跟我一起来体验！',
                imageUrl: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/share-logo@3.png',
                success: (ret) => {
                  console.log(JSON.stringify(ret))
                },
              })
            }
          },
          fail: function (res) {
            console.log(res.errMsg)
          },
        })
      },

      // 预览图片
      handlePreview(item) {
        this.previewPicSrc = item
        this.previewPic = true
      },

      // 获取年
      getYear(type) {
        const date = new Date()
        let year = date.getFullYear()
        if (type === 'start') {
          year = year - 60
        } else if (type === 'end') {
          year = year + 2
        }
        return year
      },
      goBack(index) {
        uni.navigateBack()
      },
      // 旧代码------------------------------------
      handleTouchStart(event) {
        console.log('@@@')
        // 记录开始触摸的Y坐标
        this.startY = event.touches[0].clientY
      },
      handleTouchMove(event) {
		  console.log(this.previewPic,'09090')
		  if (this.previewPic){
			  return false
		  }
        // 当前触摸的Y坐标
        const currentY = event.touches[0].clientY
        // 计算滑动的距离
        const distance = currentY - this.startY
        // 根据滑动的距离判断是上滑还是下滑
        if (distance > 6) {
          // 上滑操作
          this.isViewVisible = true
        } else if (distance < -6) {
          // 下滑操作
          this.isViewVisible = false
        }
      },
      handleTouchEnd() {
        // 可以在这里做一些触摸结束后的处理
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
    },
  }
</script>
<style lang="less" scoped>
  .box {
    padding-top: 100rpx;
    padding-bottom: 200rpx;
    width: 100%;
    height: 100vh;
    background: #fff;
    overflow: hidden;
  }

  .head {
    width: 100%;
    padding: 0 20rpx;

    .title {
      display: flex;
      justify-content: start;
      align-items: center;
      width: 100%;
      height: 60rpx;
    }

    .fanhui {
      width: 30rpx;
      height: 30rpx;
    }

    .title-text {
      position: relative;
      margin-left: 10rpx;
      width: 100%;
      font-size: 32rpx;
      font-weight: 500;
      color: #000;

      .view-resume {
        position: absolute;
        top: 10rpx;
        left: 50%;
        transform: translate(-50%, -10rpx);
        padding-top: 2rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 40rpx;
        color: #666666;
        font-weight: 500;
        font-size: 24rpx;

        .share-resume {
          margin-left: 20rpx;
          width: 30rpx;
          height: 30rpx;
        }
      }
    }

    .head_right {
      font-size: 30rpx;
      font-weight: 400;
      color: #ffffff;
    }
  }

  .main {
    height: calc(100vh - 200rpx);
    overflow-y: auto;
  }

  .section {
    position: relative;
    padding: 20rpx;
    background: #fff;
    border-radius: 20rpx;
    border-bottom: 1rpx solid #ebebeb;

    .section-title {
      display: flex;
      align-items: center;
      height: 60rpx;
      line-height: 60rpx;
      color: #000;
      font-weight: bolder;

      .title-line {
        margin-right: 10rpx;
        display: inline-block;
        width: 8rpx;
        height: 32rpx;
        background: #0fa291;
        border-radius: 4rpx;
      }

      .right-text {
        margin-left: auto;
        padding: 8rpx 16rpx;
        font-size: 24rpx;
        line-height: normal;
        color: #0fa291;
        background: #e7f5f4;
        border-radius: 4rpx;
      }

      .work-add {
        margin-left: auto;
        margin-right: 20rpx;
        padding: 8rpx 16rpx;
        color: #0fa291;
        font-size: 24rpx;
        line-height: 24rpx;
        font-weight: 500;
        background: #e7f5f4;
        border-radius: 32rpx;
        border: 1rpx solid #0fa291;
      }
    }

    .form-item {
      box-sizing: border-box;
      position: relative;
      padding: 10rpx 0;
      display: flex;
      justify-content: flex-start;
      align-items: self-start;

      .label,
      .text {
        min-width: 140rpx;
        font-size: 28rpx;
        color: #000;
      }

      .text {
        flex: 1;
        color: #000;
        white-space: wrap;
        word-break: break-all;
      }

      .arrow-right {
        margin-left: auto;
        width: 28rpx;
        height: 28rpx;
        transition: all 0.3s ease-in-out;
      }

      .form-item-tag {
        display: inline-block;
        margin: 5rpx 10rpx 5rpx 0;
        padding: 8rpx 26rpx;
        height: 40rpx;
        line-height: 40rpx;
        color: #666;
        font-size: 24rpx;
        background: #f5f7f9;
        border-radius: 4rpx;
        white-space: nowrap;
      }

      .open {
        transform: rotate(-90deg);
      }

      .seclector-box {
        position: absolute;
        top: 90%;
        left: 0;

        padding: 20rpx 10rpx;
        display: flex;
        flex-wrap: wrap;
        background: #f5f7f9;
        border: 1rpx solid #ebebed;
        border-radius: 10rpx;
        box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(24, 97, 93, 0.1);
        transition: all 0.3s ease-in-out;
      }

      .center-section {
        margin: 0 auto;
        width: 710rpx;
        background: #ffffff;
        border-radius: 20rpx;

        .content-title {
          display: flex;
          justify-content: space-between;
          align-items: center;

          .content-title-right {
            display: flex;
            align-items: center;
            color: #0fa291;
            font-size: 24rpx;
          }
        }

        .content-tip {
          margin: 20rpx 0;
          font-size: 24rpx;
          color: #e00201;
        }
      }

      .skill-img {
        margin-top: 10rpx;
      }

      /* 放在form-item 样式最后，用户覆盖未选中样式*/
      .checked {
        position: relative;
        color: #0fa291;
        background: #e7f5f4;

        &:after {
          content: '';
          position: absolute;
          bottom: 0;
          right: 0;
          width: 28rpx;
          height: 28rpx;
          background: url('https://pic.bangbangtongcheng.com/static/bbzc/checked-tag.png') center no-repeat;
          background-size: 100% 100%;
        }
      }

      /* form-item 结束*/
    }

    .bonus-item {
      width: 100%;
      flex-wrap: wrap;

      .content {
        margin: 10rpx 0;
        padding: 13rpx 20rpx;
        width: 100%;
        line-height: 56rpx;
        background: #f5f7f9;
        border-radius: 10rpx;
      }

      .certificateworks {
        width: 100%;
        color: #333;
        .scroll-view-x {
          width: 100%;
          white-space: nowrap;
        }

        .img {
          margin-right: 10rpx;
          display: inline-block;
          width: 140rpx;
          height: 140rpx;
        }
      }
    }

    .avator {
      position: absolute;
      top: 80rpx;
      right: 20rpx;
      width: 180rpx;
      height: 180rpx;
      border-radius: 90rpx;
      border: 1rpx solid #ebebed;
    }
  }

  .preview-warp {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;

    & > img {
      width: 100%;
    }
  }

  /*loding 样式开始 */
  .dengLoadingVue {
    .maskVueHiddenShow {
      z-index: 999999;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgb(255, 255, 255);
      display: flex;
      align-items: center;
      justify-content: center;

      .maskVueHiddenShowWrapper {
        width: 80%;
        height: 300rpx;
        position: fixed;
        top: 15%;
        left: 50%;
        transform: translateX(-50%);
        animation: 0.5s;

        .loding {
          width: 100%;
          text-align: center;
          position: absolute;
          bottom: 0;
          left: 50%;
          transform: translateX(-50%);
        }
      }
    }
  }

  .loader {
    position: absolute;
    top: calc(50% - 32px);
    left: calc(50% - 32px);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    perspective: 800px;
  }

  .inner {
    position: absolute;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }

  .inner.one {
    left: 0%;
    top: 0%;
    animation: rotate-one 1s linear infinite;
    border-bottom: 3px solid #64b6a8;
  }

  .inner.two {
    right: 0%;
    top: 0%;
    animation: rotate-two 1s linear infinite;
    border-right: 3px solid #64b6a8;
  }

  .inner.three {
    right: 0%;
    bottom: 0%;
    animation: rotate-three 1s linear infinite;
    border-top: 3px solid #64b6a8;
  }

  @keyframes rotate-one {
    0% {
      transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg);
    }

    100% {
      transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg);
    }
  }

  @keyframes rotate-two {
    0% {
      transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg);
    }

    100% {
      transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg);
    }
  }

  @keyframes rotate-three {
    0% {
      transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg);
    }

    100% {
      transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg);
    }
  }

  @keyframes maskVueHiddenShowWrapper {
    0% {
      width: 80%;
    }

    100% {
      width: 0;
    }
  }

  /*loding 样式结束 */

  /deep/ .u-read-more__content__inner {
    span {
      color: #000;
    }
  }
</style>
